<template>
	<view class="content">
		<view class="list" v-for="(item,index) in collectList">
			<view class="list-left" @click="goexamination(item,index)"> 
				<view class="title">
					<u-parse :content="item.extJSON.questionStemExtJson.testQuestionsContent"></u-parse>
				</view>
				<view class="" style="font-size: 26rpx;margin-top: 20rpx;">
					收藏时间：{{item.createTime}}
				</view>
			</view>
			<view class="list-right">
				<view class="start" @click="del(item)">取消</view>
			</view>
		</view>
		<view class="none_list_box" v-if="collectList.length===0" style="margin-top: 200rpx;">
			<uv-empty mode="favor" text="暂无收藏记录"></uv-empty>
		</view>
		
	</view>
</template>

<script>
	import { delPlugsCollect,insertPlugsCollect,searchPlugsCollectByUserId,getUserCollectTestQuestionsList,cancelCollectByDataId } from '../../../utils/api.js';
	export default {
		data() {
			return {
				collectList: [],
				options1: [{
					text: '删除'
				}],
				nowBusinessInfo:{},
				datalist:[]
			}
		},
		onLoad() {

		},
	
		onShow() {
			this.getcollectList()
		},
		methods: {
			
			
			getcollectList() {
				let self = this;
				let postdata = {
					page: 1,
					size: 50,
					businessId:0,
					userServiceToken: uni.getStorageSync('userInfo').userServiceToken || 'TUW8JF4WE6D52SDL5UMN5',
				}
				getUserCollectTestQuestionsList(postdata).then(res => {
					if (res.code == 200) {
						this.collectList = res.body.list;
						this.datalist=[]
						this.collectList.forEach(item=>{
							item.extJSON.questionStemExtJson=JSON.parse(item.extJSON.questionStemExtJson)
							this.datalist.push(item.extJSON)
						})
						console.log(this.collectList);
						console.log(this.collectList);
					}
				})
			},
			del(item) {
				let self = this;
				let postData={
					"dataId": item.dataId,
					"dataType": 3,
				}
				uni.showModal({
					title: '提示',
					content: '确定取消收藏吗',
					success: function(res) {
						if (res.confirm) {
							cancelCollectByDataId( postData).then(res => {
								if (res.code == 200) {
									uni.showToast({
										title: '取消成功'
									})
									self.getcollectList();
								}
							})
						} else if (res.cancel) {

						}
					}
				});
			},
			
			goexamination(item,index){
				console.log(item);
				uni.navigateTo({
					url:`/pages/user/starList/starDetail?dataList=${encodeURIComponent(JSON.stringify(this.datalist))}&indexId=${index}`
				})
			}

		}
	}
</script>

<style lang="scss" >
	page{
	background-color: #F5f5f5;
	padding: 20rpx;
	box-sizing: border-box;
}
.list {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx;
		border-bottom: 1rpx solid #f5f5f5;
		background-color: #fff;
		margin-bottom: 20rpx;
		border-radius: 20rpx;
		.list-left {
			width: 500rpx;
			.title {
				color: $uni-text-color;
				font-weight: 700;
				font-size: 28rpx;
			}
			.name {
				width: 450rpx;
				display: flex;
				align-items: center;
				padding: 10rpx 0;
				justify-content: space-between;
				font-size: 24rpx;
				color: #666;
				text {
					margin-left: 10rpx;
				}
			}
		}
		.list-right {
			.start {
				font-size: 26rpx;
				color: #fff;
				background-color: royalblue;
				width: 140rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align: center;
				border-radius: 25rpx 25rpx 0 25rpx;
			}
		}
	}

</style>
